package com.zhoug.speech.core;

import java.util.HashMap;

import androidx.annotation.Keep;

/**
 * 语音识别错误
 * @Author 35574
 * @Date 2020/7/8
 * @Description
 */
@Keep
public class SpeechError {
    private int code;
    private String error;

    private static final HashMap<Integer, String> ERRORS;

    static {
        ERRORS = new HashMap<>();
        ERRORS.put(10000, "语音识别结果为空");
        ERRORS.put(10114, "网络连接发生异常");
        ERRORS.put(10407, "appid校验失败,appid和MSC库不匹配");
        ERRORS.put(20001, "没有检查到网络");
    }

    public SpeechError() {
    }

    public SpeechError(int code) {
        this.code = code;
        this.error=initError();
    }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        if (this.code != code) {
            this.code = code;
            this.error=initError();
        }

    }
    private String initError(){
        String e = ERRORS.get(code);
        if(e==null){
            e=code+"";
        }
        return  e;
    }

    public String getError() {
        return error;
    }


    @Override
    public String toString() {
        return "code=" + code +
                ", error=" + error + "";
    }

}
